package org.hhchat.others.tercent.p2018;

import java.util.Scanner;

/**
 * Created this one by huminghao on 2018/4/5.
 */
public class P1 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n, m;
        while (scanner.hasNext()) {
            n = scanner.nextInt();
            m = scanner.nextInt();
            check(n, m);
            check2(n, m);
        }
    }

    public static void check(int n, int m) {
        int sum = (1 + n) * n / 2;
        int minusN = n / (2 * m);
        int minus = minusN * (1 + m) * m / 2 + minusN * (minusN - 1) * (2 * m * m) / 2;
        System.out.println("sum : " + sum + " minus: " + minus + " = " + (sum - 2 * minus));
    }

    public static void check2(int n, int m) {
        int flag = -1;
        long sum = 0;
        for (int i = 1; i <= n; i++) {
            if (flag == -1) {
                sum -= i;
            } else {
                sum += i;
            }
            if (i % m == 0) {
                flag = -flag;
            }
        }
        System.out.println(sum);
    }
}
